<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>AdminLTE 2 | General Form Elements</title>
        <!-- Tell the browser to be responsive to screen width -->
        <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
        <!-- Bootstrap 3.3.6 -->
        <link rel="stylesheet" href="/Public/ui/framework/bootstrap-3.3.7-dist/css/bootstrap.min.css">
        <!-- Font Awesome -->
        <link rel="stylesheet" href="/Public/ui/fonts/Font-Awesome-4.7.0/css/font-awesome.min.css">
        <!-- Ionicons -->
        <link rel="stylesheet" href="/Public/ui/fonts/ionicons-2.0.1/css/ionicons.min.css">
        <!-- Theme style -->
        <link rel="stylesheet" href="/Public/ui/adminlte/css/AdminLTE.min.css">
        <!-- AdminLTE Skins. Choose a skin from the css/skins
             folder instead of downloading all of them to reduce the load. -->
        <link rel="stylesheet" href="/Public/ui/adminlte/css/skins/_all-skins.min.css">
        <link rel="stylesheet" href="/Public/ui/plugins/datetimelib/bootstrap-datetimepicker-2.4.3/css/bootstrap-datetimepicker.min.css" />
        
    </head>
    <body class="hold-transition skin-blue">
        <!-- Horizontal Form -->
        <div class="box box-primary" style="box-shadow: none;">
            <!-- /.box-header -->
            <!-- form start -->
            
<!-- form start -->
<form class="form-horizontal" action="<?php echo U('promotionSave');?>" method="post">
    <div class="box-body">
        <table class=".xsui-datatable table table-condensed table-bordered table-striped table-hover" data-comboboxurl="<?php echo U('ProductPromption/getTreeJson');?>">
            <thead>
            <th>名称</th>
            <th>促销活动</th>
            </thead>
            <tbody>
                <?php if(is_array($list)): foreach($list as $key=>$vo): ?><tr data-promotion="<?php echo ($vo["promotion_ids"]); ?>">
                    <td><?php echo ($vo["title"]); ?><input type="hidden" name="id[]" value="<?php echo ($vo["id"]); ?>" /></td>
                    <td>
                        <?php if(is_array($promotions)): foreach($promotions as $key=>$vo2): ?><label class="checkbox-inline">
                            <input type="checkbox" name="promotion_ids_<?php echo ($vo["id"]); ?>[]" value="<?php echo ($vo2["id"]); ?>"> <?php echo ($vo2["text"]); ?>
                        </label><?php endforeach; endif; ?>
                    </td>
                </tr><?php endforeach; endif; ?>
            </tbody>
        </table>
    </div>
    <!-- /.box-body -->
    <div class="box-footer">
        <button type="button" class="btn btn-default xsui-btn-close-dialog">取消</button>
        <button type="submit" class="btn btn-primary pull-right">保存</button>
    </div>
    <!-- /.box-footer -->
</form>

        </div>
        <!-- /.box -->
        <!-- /.content -->

        <!-- jQuery 2.2.3 -->
        <script src="/Public/ui/plugins/jquery/jquery-2.2.3.min.js"></script>
        <!-- Bootstrap 3.3.6 -->
        <script src="/Public/ui/framework/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
        <!-- Layer 3.0.1 -->
        <script src="/Public/ui/plugins/dialoglib/layer-v3.0.1/layer.js"></script>
        <!-- AdminLTE App -->
        <script src="/Public/ui/adminlte/js/app.min.js"></script>
        <script src="/Public/ui/plugins/datetimelib/bootstrap-datetimepicker-2.4.3/js/bootstrap-datetimepicker.min.js"></script>
        <script src="/Public/ui/plugins/datetimelib/bootstrap-datetimepicker-2.4.3/js/locales/bootstrap-datetimepicker.zh-CN.js"></script>
        <script src="/Public/ui/plugins/editorlib/kindeditor-4.1.11/kindeditor-all-min.js"></script>
        <script src="/Public/theme/public/plugins/ajax-combobox-1.0/ajax-combobox-1.0.js"></script>
        <script src="/Public/theme/public/plugins/jquery-ajaxcombobox-1.0/jquery-ajaxcombobox-1.0.js"></script>
        <script src="/Public/ui/adminlte/js/xsApp.js"></script>
        
        
<script type="text/javascript">
    // 2017-3-23
    $('tbody tr').each(function () {
        var $tr = $(this);
        var promotion_ids = $tr.data('promotion')+'';
        if (undefined != promotion_ids && promotion_ids.length > 0) {
            var aids = promotion_ids.split(',');
            $tr.find(':checkbox').each(function () {
                var $chkbox = $(this);
                if (aids.indexOf($chkbox.val())>-1) {
                    $chkbox.prop('checked', true);
                }
            })
        }
    })
</script>

        
        <script>
            $(document).ready(function () {
                xsApp.initDialogForm();
            })
            /**
             * 单文件上传回调函数
             * @param {type} name
             * @param {type} value
             * @returns {undefined}
             * @version 1.0 2016-12-15
             */
            function single_uploader_cb(name, value) {
                var $input = $('[name="' + name + '"]');
                $input.val(value)
                //$input.parent().parent().find('img').attr('src', value).parent().attr({'href': value, 'title': value}).next().data('url', value);
                layer.closeAll();
                //$('iframe').parent().dialog('close');
            }
            /**
             * 批量文件上传回调函数
             * @param {type} name
             * @param {type} value
             * @returns {undefined}
             * @version 1.0 2016-12-15
             */
            function multi_uploader_cb(name, value) {
                var $input = $('[name="' + name + '"]');
                var str = $input.val();
                if (str.length > 0) {
                    str += '|';
                }
                str += value;
                $input.val(str);
                $('iframe').parent().dialog('close');
            }
        </script>
        
        
    </body>
</html>